<?php global $themeUI,$current_user; ?>
<script type="text/javascript">
function evaluate_coupon_amt()
{
	var coupon_code = document.getElementById('coupon_code').value;
	if(coupon_code == '')
	{
		alert('Please Enter Coupon Code');
		return false;
	}else
	{
		document.getElementById('eval_coupon_code').value = coupon_code;
		document.evaluate_coupon.submit();
	}
}

</script>
<?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/cart_detail_pag_above_title.php'))
{
	include_once(CHILDTEMPLATEPATH . '/cart_detail_pag_above_title.php');
}
?>
<div class="quick-cart">
<?php 
		$itemsInCartCount = $Cart->cartCount();
  		$cartAmount = $General->get_amount_format($payable_amt);
		//$cart_amt = $General->get_amount_format($cartAmount);
		//$cart_amt1 = $General->get_amount_format($cartAmount);
		//$cartInfo = $Cart->getcartInfo();
		
?>
<ul>
	<li><label>Total Item(s) :</label> <?php echo $itemsInCartCount; ?></li>
   	<li><label>Total amount : </label><?php echo $cartAmount; ?></li>
</ul>
</div>
<div class="new-breadcrumb">
		<span class="curve lt"></span>
		<span class="curve lb"></span>
	<ol>
    <li class="current one">Checkout</li>
    <?php if(!$current_user->data->ID){ ?><li class="two">Login/Sign Up</li> <? }?>
    <li class="three">Billing and shipping</li>
    <li class="four">Select Payment</li>
    </ol>
</div>
<div class="cart-holder">
 <?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/cart_detail_pag_below_title.php'))
{
	include_once(CHILDTEMPLATEPATH . '/cart_detail_pag_below_title.php');
}
?>
  <?php
	if($itemsInCartCount>0)
	{
	?>
    <?php if($_GET['msg']=='emptycart'){ echo "<div style='color:red'>".CART_EMPTY_MSG."</div><br />";}?>
    <form action="<?php echo site_url('/?ptype=cart&amp;cartact=upd'); ?>" method="post" name="updatecart" class="updatecart">
      <input type="hidden" name="cartprdid" value="<?php echo $i; ?>" />
      <ul>
    	<li class="row title">
		<div class="pro-name"><?php echo PRODUCTS_TEXT;?></div>
		<div class="pro-price t-align"><?php echo PRICE_TEXT;?></div>
		<div class="pro-qty t-align"><?php echo QTY_TEXT;?></div>
		<div class="pro-total t-align"><?php echo TOTAL_TEXT;?></div>
		<div class="link-remove"></div>
		</li>
        <?php
				for($i=0;$i<count($cartInfo);$i++)
				{
				global $Product;
				$post->ID=$cartInfo[$i]['product_id'];
				$product_image_arr = $Product->get_product_image($post,'small-thumb');
				if(has_post_thumbnail()){
				 	 $thumb_image_url =wp_get_attachment_image_src( get_post_thumbnail_id(),array(111,111));
					 $product_image_arr=$thumb_image_url;
			   	}
				$product_image = $product_image_arr[0];
				$product_id = $cartInfo[$i]['product_id'];
				$product_name = $cartInfo[$i]['product_name'];
				$product_qty = $cartInfo[$i]['product_qty'];
				$product_att = $cartInfo[$i]['product_att'];
				$product_att1 = $cartInfo[$i]['product_att1'];
				$product_price = $General->get_amount_format($cartInfo[$i]['product_gross_price'],1);
				$product_price_total =  $cartInfo[$i]['product_gross_price']*$cartInfo[$i]['product_qty'];
				?>
                
            <li class="row">
				<div class="pro-name">
	    		<div class="thumb-holder">
	            	<a href="<?php echo get_permalink($product_id);?>"><img src="<?php echo $product_image; ?>" alt=""  class="product_thum" /><span class="spaceball"></span></a>
	          <span class="curve lt"></span>
	          <span class="curve rt"></span>
	          <span class="curve lb"></span>
	          <span class="curve rb"></span>
	        		</div>
    		<div class="details">
            	<h3><a href="<?php echo get_permalink($product_id);?>"><?php echo $product_name;?></a></h3> 
            
            <?php
			//$Product->show_product_model_code($product_id);
			if($product_att!=''){ echo '<p>'.$product_att.'</p>'; }
		   ?></div></div>
	<div class="pro-price t-align"><?php echo $product_price; ?></div>
	<div class="pro-qty t-align"><?php $Product->cart_detail_product_qty($product_id,$product_qty,$product_att1);?>
          <span class="cart_detail_outofstock"><?php if(is_string($General->cart_detail_outofstock($product_id))){echo $General->cart_detail_outofstock($product_id);} ?></span></div>
	<div class="pro-total t-align"><?php echo $General->get_amount_format($product_price_total,1); ?></div>
	<div class="link-remove t-align"><a href="<?php echo site_url('/?ptype=cart&amp;cartact=rmv&amp;prm='.$i); ?>" title="Remove from Cart" class="remove"><?php echo REMOVE_ITEM_TEXT;?></a></div>
    <div class="bottom-curve">&nbsp;</div>
    </li>
        <?php }?>
        </ul>

    	
<?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/cart_detail_page_below_product_list.php'))
{
	include_once(CHILDTEMPLATEPATH . '/cart_detail_page_below_product_list.php');
}
?>
            <?php //if(get_option('ptthemes_qty_txt_cart_showhide')=='Editable'){?>
            <a  href="javascript:void(0);" onclick="document.updatecart.submit();" class="normal_button b_update_cart " ><?php echo UPDATE_CART_TEXT; ?></a>
			
            <?php //}?>
<?php if($current_user->data->ID){if($General->is_show_coupon()){	?>
        <div class="coupon_code">
            <?php if($_REQUEST['msg']=='invalidcoupon'){?>
              <div class="error_msg"><?php echo INVALID_COUPON_MSG;?></div>
            <?php }?>
            <?php if($_REQUEST['msg']=='couponamt'){?>
              <div class="error_msg">This Coupon code is valid only with the purchase of more than Rs
			  <?php echo $General->get_coupon_limit($_REQUEST['eval_coupon_code']); ?></div>
            <?php }?>
            <?php if($_REQUEST['msg']=='couponused'){?>
              <div class="error_msg">This coupon code has been already used</div>
            <?php }?>
            <?php if($_REQUEST['msg']=='couponerror'){?>
              <div class="error_msg"><?php echo COUPON_ERROR_MSG;?></div>
            <?php }?>
              <div class="discount-widget"><label class="fl"><?php echo DISCOUNT_CODE_TEXT;?> :</label><input type="text" class="coupon_text fl" value="<?php echo $_SESSION['eval_coupon_code'];?>" name="coupon_code" id="coupon_code" /><a href="javascript:void(0);"  onclick="evaluate_coupon_amt();"  class="fl normal_button" ><?php echo RECALCULATE_TEXT;?></a> </div>
        </div>
       <?php } }?>        
   
             <div class="total-excerpt">
             <div id="shoppingcart_outofstock_msg1" style="display:none;"></div>
          <p><label><?php echo SUB_TOTAL_AMOUNT_TEXT;?>:</label>  <?php echo  $grandTotal; ?></p>
          <?php if($taxable_amt>0) {?>
			<p><label><?php echo $taxable_info_desc;?>:</label>  <?php echo  $General->get_amount_format($taxable_amt); ?></p>
        <?php }?>
        <?php if($shipping_amt>0) { ?>
        <p><label><?php echo $General->get_shipping_method('title');?> <?php _e('Amount');?>:</label> <?php echo  $General->get_amount_format($shipping_amt);?></p>
        <?php }?>
          </div>
        <?php 
		if($cart_discount_amt){?>
        <div class="total-excerpt no-margin-t">
        <p class="fl"><label>Active Coupon: </label> <?php echo  $_SESSION['couponcode']; ?></p>
          <p><label><?php echo $couponInfo;?> : </label> <?php echo  $cart_discount_amt; ?></p>
          </div>
        <?php }?>
         <?php if($shipping_limit[0]>0) { ?>
         <div class="total-excerpt">
         <div class="shipcontent"><?php echo  $shipping_limit[1];?></div>
        <p><label>Shipping Charges</label> <?php echo  $General->get_amount_format($shipping_limit[0]);?></p>
        </div>
        <?php }?>
       <div class="total-amt">
       <div class="fr total-count">
       	<strong><?php echo TOTAL_AMOUNT_TEXT;?> : </strong><span class="large"><?php echo  $General->get_amount_format($payable_amt); ?></span></div>
       </div>
<?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/cart_detail_page_below_amount_total.php'))
{
	include_once(CHILDTEMPLATEPATH . '/cart_detail_page_below_amount_total.php');
}
?>
 </form>
      <form action="<?php global $General; echo $General->get_ssl_normal_url(site_url('/?ptype=myaccount&amp;type=address')); ?>" method="post" name="checkout_frm" >
      	<?php
        $shipping_info = $General->get_shipping_method();
		if($shipping_info)
		{
			$shipping_id = $shipping_info->shipping_id;
			$title = $shipping_info->title;
		?>
     <?php /*?> <table width="100%" <?php if($shippingcount==1){ ?> style="display:none;"<?php }?> class="checkout_frm">
        <tr>
          <td colspan="2" class="shipping_title"><strong><?php echo SHIPPING_METHODS_TEXT;?></strong></td>
        </tr>
        <tr>
          <td><?php echo $title;?></td>
          <td><input type="radio" value="<?php echo $shipping_id;?>" name="shippingmethod" checked="checked" style="display:none;" /></td>
        </tr>
      </table><?php */?>
      <?php	}?>
	</form>
    <?php
if($themeUI->is_on_guest_checkout() && !$current_user->data->ID)
{?>
<a class="highlight_button checkout_spacer fr guest_checkout_spacer " href="<?php global $General; echo $General->get_ssl_normal_url(site_url('/?ptype=checkout&amp;checkout_as_guest=1'));?>"><?php _e(GUEST_CHECKOUT_TEXT); ?></a>
<?php }?> 
<?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/cart_detail_page_above_coupon.php'))
{
	include_once(CHILDTEMPLATEPATH . '/cart_detail_page_above_coupon.php');
}
?>
	    </div> 
        <div class="cart-bottom">    
        <a href="<?php echo site_url(); ?>" class="fl continue_spacer">&laquo; <?php echo CONTINUE_SHOPPING_TEXT;?> </a> 
    	<a href="javascript:void(0);" onclick="document.checkout_frm.submit();" class="highlight_button fr checkout_spacer" ><?php echo CHECKOUT_TEXT;?></a>   
    </div>
 <?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/cart_detail_page_below_coupon.php'))
{
	include_once(CHILDTEMPLATEPATH . '/cart_detail_page_below_coupon.php');
}
?>
    <form action="<?php ?>" method="post" name="evaluate_coupon" class="evaluate_coupon">
      <input type="hidden" name="cartact" value="eval_coupon" />
      <input type="hidden" name="eval_coupon_code" id="eval_coupon_code" value="" />
    </form>
    <?php }else{?>
 <?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/cart_detail_page_above_cart_empty_msg.php'))
{
	include_once(CHILDTEMPLATEPATH . '/cart_detail_page_above_cart_empty_msg.php');
}
?>
  		    <h3><?php echo CART_EMPTY_MSG;?> </h3>
          <a href="<?php echo site_url();?>" class="highlight_button fl"><?php echo CONTINUE_SHOPPING_TEXT;?> </a>
          </div>
<?php
if(CHILDTEMPLATEPATH && file_exists(CHILDTEMPLATEPATH . '/cart_detail_page_below_cart_empty_msg.php'))
{
	include_once(CHILDTEMPLATEPATH . '/cart_detail_page_below_cart_empty_msg.php');
}
?>
          <?php  $_SESSION['couponcode'] = ''; }?>
		  <input type="hidden" name="product_quantity" id="product_quantity" value="1"/>
<script type="text/javascript">
//<![CDATA[ 
function isNumberKey1(pid,att1,prd_qty)
{
	if(document.getElementById('product_quantity'))
	document.getElementById('product_quantity').value =document.getElementById('product_qty').value;
	chkOrder(pid,att1,prd_qty);
 return true;
}
function chkOrder(pid,att1,prd_qty)
{
	var pid = pid;
	var color = "";
	var size = "";
	var attribute3 = "";
	var attribute4 = "";
	var attribute5 = "";
	var attribute6 = "";
	var attribute7 = "";
	var attribute8 = "";
	var attribute9 = "";
	var attribute10 = "";

	var qty = parseInt(document.getElementById("product_quantity").value) - prd_qty; 

	var attribute = att1.split(",");
	var i = 0;
	for(i=0; i<attribute.length; i++)
	{
		var attri = attribute[i].split("_");
		for(j=0; j<attri.length; j++)
		{
			if(attri[0] == "color")
			{
				color = attri[1];
				if(color != ""){
				color = color.replace("+","amp");
				}
			}
			if(attri[0] == "attribute3")
			{
				attribute3 = attri[1];
				if(attribute3 != ""){
				attribute3 = attribute3.replace("+","amp");
				}
			}
			if(attri[0] == "attribute4")
			{
				attribute4 = attri[1];
				if(attribute4 != ""){
				attribute4 = attribute4.replace("+","amp");
				}
			}
			if(attri[0] == "attribute5")
			{
				attribute5 = attri[1];
				if(attribute5 != ""){
				attribute5 = attribute5.replace("+","amp");
				}
			}
			if(attri[0] == "attribute6")
			{
				attribute4 = attri[1];
				if(attribute6 != ""){
				attribute6 = attribute6.replace("+","amp");
				}
			}
			if(attri[0] == "attribute7")
			{
				attribute7 = attri[1];
				if(attribute7 != ""){
				attribute7 = attribute7.replace("+","amp");
				}
			}
			if(attri[0] == "attribute8")
			{
				attribute8 = attri[1];
				if(attribute8 != ""){
				attribute8 = attribute8.replace("+","amp");
				}
			}if(attri[0] == "attribute9")
			{
				attribute9 = attri[1];
				if(attribute9 != ""){
				attribute9 = attribute9.replace("+","amp");
				}
			}
			if(attri[0] == "attribute10")
			{
				attribute10 = attri[10];
				if(attribute10 != ""){
				attribute10 = attribute10.replace("+","amp");
				}
			}
			if(attri[0] == "size")
			{
				
				size = attri[1];
				if(size!=""){
					 size = size.replace("+","amp");
				}
			}
			}
		}

	if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp = new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {
  	if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
		if(xmlhttp.responseText != "")
		{
			if(xmlhttp.responseText == "false")
			{
				if(document.getElementById("shoppingcart_button_1"))
				{
					document.getElementById("shoppingcart_button_1").style.display="none";
				} 
				if(document.getElementById("shoppingcart_outofstock_msg1"))
				{
					document.getElementById("shoppingcart_outofstock_msg1").style.display = "";
					document.getElementById("shoppingcart_outofstock_msg1").innerHTML="this product is out of stock";
				}
			}
			else if(xmlhttp.responseText == "true")
			{
				if(document.getElementById("shoppingcart_outofstock_msg1"))
				{
					document.getElementById("shoppingcart_outofstock_msg1").style.display = "none";
					document.getElementById("shoppingcart_outofstock_msg1").innerHTML="";
					document.getElementById("shoppingcart_button_1").style.display="";
				}
			}
		}
     }
  }

xmlhttp.open("GET","<?php echo get_template_directory_uri();  ?>/chkorder.php?color="+color+"&size="+size+"&pid="+pid+"&qty="+qty+"&attribute3="+attribute3+"&attribute4="+attribute4+"&attribute5="+attribute5+"&attribute6="+attribute6+"&attribute7="+attribute7+"&attribute8="+attribute8+"&attribute9="+attribute9+"&attribute10="+attribute10,true);
xmlhttp.send();
}
//]]> 
</script>